<?
header('Access-Control-Allow-Origin: *');
//header('Content-type: application/x-javascript');  // output as JSON
require_once('db/db.php');
$db = new DBConnection('dbname=assclap_realty port=5432 user=assclap_assclap password=fibo1235');
if (isset($_GET['mls_id']))
{
	$mls_id = $_GET['mls_id'];
	$comments = addslashes($_GET['comments']);
	$rating = $_GET['rating'];
	$sql = "select count(*) as cnt from property_aux where mls_id = $mls_id";
	$Query = $db->CreateQuery($sql);
	$r = $Query->FetchObject();
	if($r->cnt == 0)
	{
		$sql = "INSERT INTO property_aux (mls_id, comments, rating) VALUES ($mls_id, '$comments', $rating)";
	}
	else
	{
		$sql = "UPDATE property_aux set comments = '$comments', rating = $rating WHERE mls_id = $mls_id";
	}
	//user_error($sql);
	$db->CreateQuery($sql);
} 
//echo json_encode($R);
?>